<template>
	<view class="main">
		<view class="container" v-if="imageUrl" v-for="(item,index) in imageUrl" :key="index" style="margin-top: 20rpx;">
		    <view  class="preview" @click="handleEntItem(item)" style="position: relative;">
			  <view v-if="item.status == 1" class="mask mask2"><u-icon name="checkmark-circle-fill" label="已认领" color="#5ac725" labelColor='#5ac725' ></u-icon></view>
			  <view v-if="item.status!=1" class="mask mask1">
			  	<view v-if="item.status == 0" style="color: #fa3534;font-size: 35rpx;">审核失败，点击重新上传</view>
				<view v-if="item.status == 2" style="color: #f29100;font-size: 35rpx;">审核中</view>
			  </view>
		      <image v-if="item.clicense" :src="item.clicense" mode="aspectFill"></image>
			  <view class="inner" v-else >
				  <view v-if="(item.status == 1)&&!item.clicense" class="innerif" style="color: white;background-color: #5ac725; width:600rpx;height: 300rpx;display: flex; align-items: center; justify-content: center;font-size: 50rpx;">
				  	<text>您已通过审核</text>
				  </view>
				  <view  v-else style="display: flex;flex-direction: column;">
				  	<text  class="add">+</text>
				  	 <text>请上传营业执照</text>
				  </view>
			  </view>
			  
		    </view>
		  </view>
		  <view class="container" style="margin-top: 20rpx;">
		      <view  class="preview" @click="handleEntItem()">
		  	  <view class="inner">
		  		  <view  style="display: flex;flex-direction: column;">
		  		  	<text  class="add">+</text><text>请上传营业执照</text>
		  		  </view>
		  	  </view>
		      </view>
		    </view>
		  
		  <view v-if="rlentlist" style="margin-left: 40rpx;font-weight: 600;font-size: 30rpx;margin-top: 40rpx;">
		  	<u-icon name="arrow-down-fill" label='企业认领'></u-icon>
		  </view>
		  <view v-if="rlentlist" class="entclaim" v-for="(item,index) in rlentlist" :key="index">
		  	<view class="">
		  		<u--image :showLoading="true"
		  			:src="item.logo?item.logo: 'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/default-avatar.png'" 
		  		  width='120rpx'height="120rpx" shape="circle"></u--image>
		  	</view>
		  	<view class="" style="padding: 0 20rpx;font-size: 32rpx; font-weight: 600;">
		  		{{item.entName}}
		  	</view>
		  	<view>
		  		<u-button v-if="item.status == 3" text="认领" type="primary" size='small' @click="claim(item.id)"></u-button>
				<u-button v-if="item.status == 4" text="认领审核中" type="warning" size='small'></u-button>
		  	</view>
		  </view>
		  <u-popup :show="showClaimWay" mode="center" @close="closeClaimWay" closeable closeOnClickOverlay :safeAreaInsetBottom="false" round = '10' customStyle="width:70%">
		              <view style="margin: 10rpx auto;padding: 20rpx;">
		                  <text>选择认领方式</text>
		              </view>
					  <view class="" style="width: 80%;display: flex;margin-top: 40rpx; margin: 20rpx auto;">
					  	<u-button  type="success" @click="toClaim(0)">法人身份证</u-button>
					  	<u-button  type="primary" @click="toClaim(1)">授权委托书</u-button>
					  </view>
		  </u-popup>
	</view>
</template>

<script>
import Index from "@/common/index-model.js"	
import fun from "@/common/publicFun.js"	
let index = new Index()
let that = this
export default {
	data() {
		return {
			 imageUrl: [], // 用于预览图片的地址
			 // status:'',//审核状态
			 // isEnterprising:'',//是否正在审核
			 // hasEnterprise:'',//审核结果
			 showuploadImage:true,
			//
			inputForm:{
				id:'',
				clicense:'',
				entName:'',
				regNo:'',
				realName:'',
				idNo:''
			},
			status:0,
			rlentlist:[],
			showClaimWay:false,
			choiceid:0,
		}
	},
	methods: {
		toClaim(type){
			this.showClaimWay = false
			console.log("去认领")
			uni.navigateTo({
				url: "/pagesC/my/claimEnt?type="+type+ '&entid=' + this.choiceid
			})
		},
		claim(itemid){
			console.log("认领",itemid)
			this.choiceid = itemid
			this.showClaimWay = true
		},
		closeClaimWay(){
			this.showClaimWay = false
		},
		getrlent(){
			index.getPublicUserMember({}, '/client/realauth/myEnterpriseClaimList', 'get', res => {
				if (res.data.code == 200 && res.data.success) {
					console.log("企业认领列表",res.data.result)
					this.rlentlist = res.data.result
				}else{
					
				}
			})
		},
		handleEntItem(data){
			let url = JSON.stringify(data)
			console.log("点击",data)
			if(data){
				uni.navigateTo({
				url: "/pagesB/entRegister/entRegister?type=1&data=" + url
			})
			}else{
				uni.navigateTo({
					url: "/pagesB/entRegister/entRegister?type=1"
				})
			}
			
		},
		// getPostInfo() {
		// 	index.getPublicUserMember({},'/client/enterprise/info/detailNew','get',res=>{
		// 		console.log(res.data.success,"结果")
		// 		if(res.data.result.status != 0){
		// 			this.imageUrl = res.data.result.clicense
		// 		}
		// 			this.inputForm.id = res.data.result.id
				
		// 	})
		// },
		getPostInfo1() {
			index.getPublicUserMember({},'/client/realauth/myEnterpriseAuthList','get',res=>{
				console.log("新列表",res)
				if (res.data.code == 200 && res.data.success) {
					this.imageUrl = res.data.result
				}
			})
		}
		// getState() {
		// 	index.getPublicUserMember({},'/client/enterprise/info/enterpriseStatus','get',res=>{
		// 		console.log(res.data.result)
		// 		this.status = res.data.result.status
		// 		this.isEnterprising = res.data.result.isEnterprising
		// 		this.hasEnterprise = res.data.result.hasEnterprise
		// 		if(res.data.result.status == 0){
		// 			index.show_tips('认证失败,请重新上传')
		// 			this.shouldChooseImage = true
		// 			this.imageUrl =""
		// 		}
				
		// 	})
		// }
	},
	onShow() {
		this.getrlent()
		this.getPostInfo1()
	},
	onLoad() {
		this.imageUrl =""
		// this.getPostInfo()
		this.getPostInfo1()
		// this.getState()
		this.getrlent()
	},

}
</script>

<style>
	.entclaim {
		margin: 0 auto;
		width: 90%;
		border-radius: 14rpx;
		box-shadow: 0px 2px 4px -2px rgba(0, 0, 0, 0.1), 0px 4px 6px -1px rgba(0, 0, 0, 0.1);
		padding: 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
</style>

<style>
@import url("@/static/css/publics.css");
@import url("@/static/css/myeditphone.css");
.mask{
	position: absolute;
	width: 100%;
	height: 100%;
	display: flex;
	padding: 20rpx;
	box-sizing: border-box;
}
.mask1{
	background-color: rgba(100, 100, 100, 0.5); /* 灰色半透明 */
	align-items: flex-end;
	justify-content: center;
	text-shadow: 2px 2px 3px rgba(255, 255, 255, 0.8); /* 白色阴影 */
}
.mask2{
	align-items: flex-start;
	justify-content: flex-end;
}
</style>